package org.rsbot.script.methods;

import java.util.Random;

public abstract class MethodProvider
{
  protected final MethodContext methods;

  public MethodProvider(MethodContext paramMethodContext)
  {
    this.methods = paramMethodContext;
  }

  public int random(int paramInt1, int paramInt2)
  {
    return paramInt1 + (paramInt2 == paramInt1 ? 0 : this.methods.random.nextInt(paramInt2 - paramInt1));
  }

  public int random(int paramInt1, int paramInt2, int paramInt3) {
    int i = paramInt1 + (paramInt2 - paramInt1) / 2;
    int j;
    do j = (int)(this.methods.random.nextGaussian() * paramInt3 + i);
    while ((j < paramInt1) || (j >= paramInt2));
    return j;
  }

  public int random(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    int i;
    do
      i = (int)(this.methods.random.nextGaussian() * paramInt4 + paramInt3);
    while ((i < paramInt1) || (i >= paramInt2));
    return i;
  }

  public double random(double paramDouble1, double paramDouble2)
  {
    return paramDouble1 + this.methods.random.nextDouble() * (paramDouble2 - paramDouble1);
  }

  public void sleep(int paramInt)
  {
    try
    {
      long l1 = System.currentTimeMillis();
      Thread.sleep(paramInt);
      long l2;
      while (l1 + paramInt > (l2 = System.currentTimeMillis()))
        Thread.sleep(l1 + paramInt - l2);
    }
    catch (InterruptedException localInterruptedException)
    {
    }
  }
}